home *** CD-ROM | disk | FTP | other *** search
/ Geek Games #12 / GEGA012.iso / Jogos de Azar / fruit.swf / scripts / C_DealButtonCLASS.as < prev    next >
Text File  |  2006-01-17  |  3KB  |  122 lines

  1. _global.C_DealButtonCLASS = function()
  2. {
  3.    AsBroadcaster.initialize(this);
  4.    this.init();
  5. };
  6. C_DealButtonCLASS.prototype = new MovieClip();
  7. C_DealButtonCLASS.prototype.init = function()
  8. {
  9.    this.keys = [13];
  10.    this.onKeyDown = function()
  11.    {
  12.       var a = this.keys;
  13.       var k = Key.getCode();
  14.       var i = 0;
  15.       while(i < a.length)
  16.       {
  17.          if(k == a[i])
  18.          {
  19.             this.onButtonPress();
  20.          }
  21.          i++;
  22.       }
  23.    };
  24.    var b = this.dealButton_btn;
  25.    b.onRelease = function()
  26.    {
  27.       this._parent.onButtonPress();
  28.    };
  29.    b.onRollOver = b.onDragOver = function()
  30.    {
  31.       this._parent.onButtonFocus();
  32.    };
  33.    b.onDragOut = b.releaseOutside = b.onRollOut = function()
  34.    {
  35.       this._parent.onButtonBlur();
  36.    };
  37.    if(b)
  38.    {
  39.       Key.addListener(this);
  40.    }
  41.    if(this.label != undefined)
  42.    {
  43.       this.setLabel(this.label);
  44.    }
  45. };
  46. C_DealButtonCLASS.prototype.lock = function()
  47. {
  48.    this.locked = true;
  49.    this.onRelease = function()
  50.    {
  51.    };
  52.    this.useHandCursor = false;
  53.    this.dealButton_btn._brightness = -40;
  54.    this.label_mc._brightness = -40;
  55.    this.onButtonBlur();
  56. };
  57. C_DealButtonCLASS.prototype.unlock = function()
  58. {
  59.    this.locked = false;
  60.    delete this.onRelease;
  61.    delete this.useHandCursor;
  62.    this.dealButton_btn._brightness = 0;
  63.    this.label_mc._brightness = 0;
  64. };
  65. C_DealButtonCLASS.prototype.onButtonPress = function()
  66. {
  67.    if(this.locked)
  68.    {
  69.       return undefined;
  70.    }
  71.    if(this.hint != undefined)
  72.    {
  73.       this.hideAlt();
  74.    }
  75.    var c = this.client;
  76.    c.client[c.handler]();
  77.    this.client.client._caller = this;
  78.    this.broadcastMessage("onPress");
  79. };
  80. C_DealButtonCLASS.prototype.onButtonFocus = function()
  81. {
  82.    if(this.locked)
  83.    {
  84.       return undefined;
  85.    }
  86.    if(this.hint != undefined)
  87.    {
  88.       this.showAlt(this.hint);
  89.    }
  90.    this.client.client._caller = this;
  91.    this.broadcastMessage("onFocus");
  92. };
  93. C_DealButtonCLASS.prototype.onButtonBlur = function()
  94. {
  95.    if(this.hint != undefined)
  96.    {
  97.       this.hideAlt();
  98.    }
  99.    this.client.client._caller = this;
  100.    this.broadcastMessage("onBlur");
  101. };
  102. C_DealButtonCLASS.prototype.setChangeHandler = function(handler, client)
  103. {
  104.    this.client = {handler:handler,client:client};
  105. };
  106. C_DealButtonCLASS.prototype.setKeys = function()
  107. {
  108.    this.keys = [];
  109.    var i = 0;
  110.    while(i < arguments.length)
  111.    {
  112.       this.keys.push(arguments[i]);
  113.       i++;
  114.    }
  115. };
  116. C_DealButtonCLASS.prototype.setLabel = function(label)
  117. {
  118.    this.label_mc.gotoAndStop(label);
  119. };
  120. ASSetPropFlags(_global,"C_DealButtonCLASS",131);
  121. Object.registerClass("C_DealButtonCLASS",C_DealButtonCLASS);
  122.